﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using BestLifePOS_Core.Exceptions.DataBase;

namespace BestLifePOS_Core.Data.Core
{
    public abstract class BestLifeDataAction<T>
    {
        public BestLifeDataAction() { }

        public abstract T Body(SqlConnection PConn);

        public T execute()
        {
            SqlConnection LvConn = new SqlConnection(RuntimeConstants.GvConnString);
            T LvResult;

            try
            {
                LvConn.Open();
                LvResult = Body(LvConn);
            }
            catch (Exception ex)
            {
                string LvA = ex.Message;
                throw ex;
            }
            finally
            {
                LvConn.Close();
            }

            return LvResult;
        }
    }
}
